<?php
class Albums extends BaseController {


	public function __construct() {
		parent::__construct();
		$this->load->model('AlbumsModel');
		$this->load->model('UploadModel');
	}

	public function viewAlbums() {
		if (isset($_SESSION['user'])) {
			$albums = $this->AlbumsModel->getAlbumNames($_SESSION['user']);
			$this->master_view('albums',array('albums' => $albums,'edit_mode' => '0'));
		} else {
			$this->master_view('welcome',array());
		}
	}

	public function viewImages() {
		if (isset($_SESSION['user'])) {
			$album_name = $_GET['album_name'];
			$pics = $this->AlbumsModel->fetchPics($_SESSION['user'],$album_name);
			$this->master_view('pics',array('pics' => $pics));
		} else {
			$this->master_view('welcome',array());
		}
	}

	public function addImages() {
		if (isset($_SESSION['user'])) {
			$album_name = $_GET['album_name'];
			$this->master_view('upload',array('album_name' => $album_name));
		} else {
			$this->master_view('welcome',array());
		}
	}
	
		public function addAlbum() {
		if (isset($_SESSION['user'])) {
			$this->master_view('upload',array('new_album' => '1'));
		} else {
			$this->master_view('welcome',array());
		}
	}
	

	public function editAlbums() {
		if (isset($_SESSION['user'])) {
			$albums = $this->AlbumsModel->getAlbumNames($_SESSION['user']);
			$this->master_view('albums',array('albums' => $albums,'edit_mode' => '1'));
		} else {
			$this->master_view('welcome',array());
		}
	}

}